import { Context, Next } from 'koa'
import { fail } from './ResResult'
const globalException = async (ctx: Context, next: Next) => {
  console.log('进入到通用异常')
  try {
    await next()
  } catch (error: any) {
    ctx.status = error.status || 500
    ctx.body = fail('服务器错误' + error.message)
    console.log(error.message)
  }
}

export default globalException
